﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WF.Common;
using System.Web.UI.HtmlControls;
using WF.ViewModels;

namespace WF.Web.Pages.WorkflowInfo
{
    public partial class ShowStatusChart : BasePage
    {
        public string bizDataID = "";
        public int procInstID = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            this.bizDataID = Request.QueryString.Get("bizdataID");
            //获取ProcInstID
            if (this.bizDataID != null && this.bizDataID != string.Empty)
            {
                WF.ViewModels.WorkflowInfo.ShowStatusChartVM ssc = new WF.ViewModels.WorkflowInfo.ShowStatusChartVM();
                this.procInstID = ssc.GetProcInstIDByBizDataID(this.bizDataID);
            }
            else
            {
                this.GetProcInstID();
            }

            //加载流程名称
            WF.ViewModels.WorkflowInfo.ShowStatusChartVM vm = new ViewModels.WorkflowInfo.ShowStatusChartVM();
            try { this.lblFolio.Text = vm.GetFolioByProcInstID(this.procInstID); }
            catch { }


            //加载当前审批人,通过procinstid
            this.ObjectDataSource1.SelectParameters.Add("procInstID", this.procInstID.ToString());
            this.dataListView.DataSource = this.ObjectDataSource1;
            this.dataListView.DataBind();

            //CreateFrameSets();
        }

        private void GetProcInstID()
        {
            string p = Page.Request.QueryString.Get("ProcInstID");
            if (p == null || p == "")
            {
                throw new BusinessException("无效的参数ProcInstID!");
            }
            else
            {
                try
                {
                    this.procInstID = int.Parse(p);
                }
                catch
                {
                    throw new BusinessException("无效的参数ProcInstID!");
                }
            }
        }

        protected void CreateFrameSets()
        {
            HtmlGenericControl frameSet = new HtmlGenericControl("frameset");
            frameSet.Attributes["cols"] = "150,*";
            frameSet.ID = "framSets";

            HtmlGenericControl navFlowType = new HtmlGenericControl("frame");
            navFlowType.Attributes["src"] = "FlowTypeList.aspx?ProcInstID=" + this.procInstID;
            navFlowType.Attributes["name"] = "navFlowType";
            navFlowType.Attributes["scrolling"] = "no";
            navFlowType.Attributes["marginwidth"] = "2";
            navFlowType.Attributes["marginheight"] = "2";
            navFlowType.ID = "navFlowType";
            frameSet.Controls.Add(navFlowType);


            HtmlGenericControl flowCenter = new HtmlGenericControl("frame");
            flowCenter.Attributes["src"] = "";
            flowCenter.Attributes["name"] = "flowCenter";
            flowCenter.Attributes["scrolling"] = "yes";
            flowCenter.Attributes["marginwidth"] = "2";
            flowCenter.Attributes["marginheight"] = "2";
            flowCenter.ID = "flowCenter";
            frameSet.Controls.Add(flowCenter);

            this.Page.Header.Controls.Add(frameSet);
        }
    }
}